<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>珠峰架构师成长计划</title>
    <link rel="stylesheet" type="text/css" href="../static/css/main.css">
</head>
<body>
<div class="nav">
    <div class="logo">
        
            珠峰架构师成长计划
        
    </div>
<ul><li><a href="../index.html">0.Async</a></li><li><a href="../html/0.editor.html">0.editor</a></li><li><a href="../html/0.module.html">0.module</a></li><li><a href="../html/1.ES2015.html">1.ES2015</a></li><li><a href="../html/2.Promise.html">2.Promise</a></li><li><a href="../html/3.Node.html">3.Node</a></li><li><a href="../html/4.NodeInstall.html">4.NodeInstall</a></li><li><a href="../html/5.REPL.html">5.REPL</a></li><li><a href="../html/6.NodeCore.html">6.NodeCore</a></li><li><a href="../html/7.module&NPM.html">7.module&NPM</a></li><li><a href="../html/8.Encoding.html">8.Encoding</a></li><li><a href="../html/9.Buffer.html">9.Buffer</a></li><li><a href="../html/10.fs.html">10.fs</a></li><li><a href="../html/11.Stream-1.html">11.Stream-1</a></li><li><a href="../html/11.Stream-2.html">11.Stream-2</a></li><li><a href="../html/11.Stream-3.html">11.Stream-3</a></li><li><a href="../html/11.Stream-4.html">11.Stream-4</a></li><li><a href="../html/12-Network-2.html">12-Network-2</a></li><li><a href="../html/12.NetWork-3.html">12.NetWork-3</a></li><li><a href="../html/12.Network-1.html">12.Network-1</a></li><li><a href="../html/13.tcp.html">13.tcp</a></li><li><a href="../html/14.http-1.html">14.http-1</a></li><li><a href="../html/14.http-2.html">14.http-2</a></li><li><a href="../html/15.compress.html">15.compress</a></li><li><a href="../html/16.crypto.html">16.crypto</a></li><li><a href="../html/17.process.html">17.process</a></li><li><a href="../html/18.yargs.html">18.yargs</a></li><li><a href="../html/19.cache.html">19.cache</a></li><li><a href="../html/20.action.html">20.action</a></li><li><a href="../html/21.https.html">21.https</a></li><li><a href="../html/22.cookie.html">22.cookie</a></li><li><a href="../html/23.session.html">23.session</a></li><li><a href="../html/24.express-1.html">24.express-1</a></li><li><a href="../html/24.express-2.html">24.express-2</a></li><li><a href="../html/24.express-3.html">24.express-3</a></li><li class="active"><a href="../html/24.express-4.html">24.express-4</a></li><li><a href="../html/25.koa-1.html">25.koa-1</a></li><li><a href="../html/26.webpack-1-basic.html">26.webpack-1-basic</a></li><li><a href="../html/26.webpack-2-optimize.html">26.webpack-2-optimize</a></li><li><a href="../html/26.webpack-3.tapable.html">26.webpack-3.tapable</a></li><li><a href="../html/26.webpack-4-AST.html">26.webpack-4-AST</a></li><li><a href="../html/26.webpack-5-source.html">26.webpack-5-source</a></li><li><a href="../html/26.webpack-6-loader.html">26.webpack-6-loader</a></li><li><a href="../html/26.webpack-7-plugin.html">26.webpack-7-plugin</a></li><li><a href="../html/26.webpack-8-hand.html">26.webpack-8-hand</a></li><li><a href="../html/27.react-1.html">27.react-1</a></li><li><a href="../html/27.react-2.html">27.react-2</a></li><li><a href="../html/27.react-3.html">27.react-3</a></li><li><a href="../html/27.react-4-immutable.html">27.react-4-immutable</a></li><li><a href="../html/27.react-5-react-dom-diff.html">27.react-5-react-dom-diff</a></li><li><a href="../html/27.react-6.html">27.react-6</a></li><li><a href="../html/28.react-mobx.html">28.react-mobx</a></li><li><a href="../html/28.redux-0.html">28.redux-0</a></li><li><a href="../html/28.redux-1.html">28.redux-1</a></li><li><a href="../html/28.redux-2-中间件.html">28.redux-2-中间件</a></li><li><a href="../html/28.redux-3-saga.html">28.redux-3-saga</a></li><li><a href="../html/28.redux-jwt-back.html">28.redux-jwt-back</a></li><li><a href="../html/28.redux-jwt-front.html">28.redux-jwt-front</a></li><li><a href="../html/29.mongodb-1.html">29.mongodb-1</a></li><li><a href="../html/29.mongodb-2.html">29.mongodb-2</a></li><li><a href="../html/29.mongodb-3.html">29.mongodb-3</a></li><li><a href="../html/29.mongodb-4.html">29.mongodb-4</a></li><li><a href="../html/29.mongodb-5.html">29.mongodb-5</a></li><li><a href="../html/29.mongodb-6.html">29.mongodb-6</a></li><li><a href="../html/30.cms-1-mysql.html">30.cms-1-mysql</a></li><li><a href="../html/30.cms-2-mysql.html">30.cms-2-mysql</a></li><li><a href="../html/30.cms-3-mysql.html">30.cms-3-mysql</a></li><li><a href="../html/30.cms-4-egg.html">30.cms-4-egg</a></li><li><a href="../html/30.cms-5-api.html">30.cms-5-api</a></li><li><a href="../html/30.cms-6-roadhog.html">30.cms-6-roadhog</a></li><li><a href="../html/30.cms-7-umi.html">30.cms-7-umi</a></li><li><a href="../html/30.cms-8-dva.html">30.cms-8-dva</a></li><li><a href="../html/30.cms-9-dva.html">30.cms-9-dva</a></li><li><a href="../html/30.cms-10-front.html">30.cms-10-front</a></li><li><a href="../html/30.cms-11-deploy.html">30.cms-11-deploy</a></li><li><a href="../html/33.redis.html">33.redis</a></li><li><a href="../html/34.unittest.html">34.unittest</a></li><li><a href="../html/35.jwt.html">35.jwt</a></li><li><a href="../html/36.websocket-1.html">36.websocket-1</a></li><li><a href="../html/36.websocket-2.html">36.websocket-2</a></li><li><a href="../html/38.chat-api-1.html">38.chat-api-1</a></li><li><a href="../html/38.chat-api-2.html">38.chat-api-2</a></li><li><a href="../html/38.chat-3.html">38.chat-3</a></li><li><a href="../html/38.chat-api-3.html">38.chat-api-3</a></li><li><a href="../html/38.chat.html">38.chat</a></li><li><a href="../html/38.chat2.html">38.chat2</a></li><li><a href="../html/38.chat2.html">38.chat2</a></li><li><a href="../html/39.crawl-0.html">39.crawl-0</a></li><li><a href="../html/39.crawl-1.html">39.crawl-1</a></li><li><a href="../html/39.crawl-2.html">39.crawl-2</a></li><li><a href="../html/40.deploy.html">40.deploy</a></li><li><a href="../html/41.safe.html">41.safe</a></li><li><a href="../html/42.test.html">42.test</a></li><li><a href="../html/43.nginx.html">43.nginx</a></li><li><a href="../html/44.enzyme.html">44.enzyme</a></li><li><a href="../html/45.docker.html">45.docker</a></li><li><a href="../html/46.elastic.html">46.elastic</a></li><li><a href="../html/47.oauth.html">47.oauth</a></li><li><a href="../html/48.wxpay.html">48.wxpay</a></li><li><a href="../html/49.nunjucks.html">49.nunjucks</a></li><li><a href="../html/50.ketang.html">50.ketang</a></li><li><a href="../html/index.html">index</a></li><li><a href="../html/51.typescript.html">51.typescript</a></li><li><a href="../html/52.UML.html">52.UML</a></li><li><a href="../html/53.design.html">53.design</a></li><li><a href="../html/index.html">index</a></li><li><a href="../html/54.linux.html">54.linux</a></li><li><a href="../html/55.yaml.html">55.yaml</a></li><li><a href="../html/50.ketang2.html">50.ketang2</a></li><li><a href="../html/56.ts.html">56.ts</a></li><li><a href="../html/57.ts_react.html">57.ts_react</a></li><li><a href="../html/58.react-ssr.html">58.react-ssr</a></li><li><a href="../html/59.react-ssr.html">59.react-ssr</a></li></ul></div>


<div class="warpper">

    <div class="page-toc">
        <ul><li><a href="#t01. 静态文件中间件">1. 静态文件中间件</a></li><li><a href="#t12. body-parser中间件">2. body-parser中间件</a><ul><li><a href="#t22.1 http报文头">2.1 http报文头</a></li><li><a href="#t32.2 body-parser工作">2.2 body-parser工作</a></li><li><a href="#t42.3 处理内容类型">2.3 处理内容类型</a><ul><li><a href="#t52.3.1 处理text/plain">2.3.1 处理text/plain</a></li><li><a href="#t62.3.2 处理application/json">2.3.2 处理application/json</a></li><li><a href="#t72.3.3 处理application/x-www-form-urlencoded">2.3.3 处理application/x-www-form-urlencoded</a></li></ul></li></ul></li><li><a href="#t82.4 处理不同编码">2.4 处理不同编码</a></li><li><a href="#t92.5 处理不同压缩类型">2.5 处理不同压缩类型</a></li><li><a href="#t102.6 multipart/form-data">2.6 multipart/form-data</a></li></ul>
    </div>
    
    <div class="content markdown-body">
        <h2 id="t01. &#x9759;&#x6001;&#x6587;&#x4EF6;&#x4E2D;&#x95F4;&#x4EF6;">1. &#x9759;&#x6001;&#x6587;&#x4EF6;&#x4E2D;&#x95F4;&#x4EF6; <a href="#t01. &#x9759;&#x6001;&#x6587;&#x4EF6;&#x4E2D;&#x95F4;&#x4EF6;"> # </a></h2>
<pre><code>express.static(root, [options])
</code></pre><p><code>express.static</code>&#x662F; Express &#x5185;&#x7F6E;&#x7684;&#x552F;&#x4E00;&#x4E00;&#x4E2A;&#x4E2D;&#x95F4;&#x4EF6;&#x3002;&#x662F;&#x57FA;&#x4E8E; serve-static &#x5F00;&#x53D1;&#x7684;&#xFF0C;&#x8D1F;&#x8D23;&#x6258;&#x7BA1; Express &#x5E94;&#x7528;&#x5185;&#x7684;&#x9759;&#x6001;&#x8D44;&#x6E90;&#x3002;</p>
<ul>
<li>root &#x53C2;&#x6570;&#x6307;&#x7684;&#x662F;&#x9759;&#x6001;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#x6240;&#x5728;&#x7684;&#x6839;&#x76EE;&#x5F55;&#x3002;</li>
<li>options &#x5BF9;&#x8C61;&#x662F;&#x53EF;&#x9009;&#x7684;&#xFF0C;&#x652F;&#x6301;&#x4EE5;&#x4E0B;&#x5C5E;&#x6027;&#xFF1A;</li>
</ul>
<table>
<thead>
<tr>
<th style="text-align:left">&#x5C5E;&#x6027;</th>
<th style="text-align:left">&#x63CF;&#x8FF0;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x9ED8;&#x8BA4;&#x503C;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">dotfiles</td>
<td style="text-align:left">&#x63A7;&#x5236;&#x70B9;&#x6587;&#x4EF6;&#x670D;&#x52A1;&#xFF0C;&#x53EF;&#x9009;&#x503C;&#x4E3A;allow,deny,&apos;ignore&apos;</td>
<td style="text-align:left">String</td>
<td style="text-align:left">&#x201C;ignore&#x201D;</td>
</tr>
<tr>
<td style="text-align:left">etag</td>
<td style="text-align:left">&#x63A7;&#x5236;etag&#x751F;&#x6210;</td>
<td style="text-align:left">Boolean</td>
<td style="text-align:left">true</td>
</tr>
<tr>
<td style="text-align:left">extensions</td>
<td style="text-align:left">&#x8BBE;&#x7F6E;&#x6587;&#x4EF6;&#x540E;&#x7F00;&#x540D;&#x8865;&#x5145;</td>
<td style="text-align:left">Boolean</td>
<td style="text-align:left">false</td>
</tr>
<tr>
<td style="text-align:left">index</td>
<td style="text-align:left">&#x8BBE;&#x7F6E;&#x76EE;&#x5F55;&#x8BBF;&#x95EE;&#x7684;&#x8FD4;&#x56DE;&#xFF0C;&#x8BBE;&#x7F6E;&#x4E3A;false&#x53EF;&#x4EE5;&#x7981;&#x6B62;&#x76EE;&#x5F55;&#x8BBF;&#x95EE;</td>
<td style="text-align:left">Mixed</td>
<td style="text-align:left">&#x201C;index.html&#x201D;</td>
</tr>
<tr>
<td style="text-align:left">lastModified</td>
<td style="text-align:left">&#x6839;&#x636E;&#x6587;&#x4EF6;&#x4FEE;&#x6539;&#x65F6;&#x95F4;&#x8BBE;&#x7F6E;Last-Modified&#x62A5;&#x5934;</td>
<td style="text-align:left">Boolean</td>
<td style="text-align:left">true</td>
</tr>
<tr>
<td style="text-align:left">maxAge</td>
<td style="text-align:left">&#x8BBE;&#x7F6E;Cache-Control&#x62A5;&#x5934;&#x7684;&#x7F13;&#x5B58;&#x63A7;&#x5236;&#x65F6;&#x95F4;&#xFF0C;&#x5355;&#x4F4D;&#x4E3A;&#x6BEB;&#x79D2;</td>
<td style="text-align:left">Number</td>
<td style="text-align:left">0</td>
</tr>
<tr>
<td style="text-align:left">redirect</td>
<td style="text-align:left">&#x5F53;&#x8DEF;&#x5F84;&#x540D;&#x662F;&#x76EE;&#x5F55;&#x65F6;&#xFF0C;&#x91CD;&#x5B9A;&#x5411;&#x5230;&#x5305;&#x542B;&#x7ED3;&#x5C3E;/&#x7684;&#x76EE;&#x5F55;</td>
<td style="text-align:left">Boolean</td>
<td style="text-align:left">true</td>
</tr>
<tr>
<td style="text-align:left">setHeaders</td>
<td style="text-align:left">&#x51FD;&#x6570;&#x7528;&#x4E8E;&#x4E3A;&#x6587;&#x4EF6;&#x8BBE;&#x7F6E;HTTP&#x5934;</td>
<td style="text-align:left">Function</td>
</tr>
</tbody>
</table>
<p>&#x5173;&#x4E8E;&#x6B64;&#x4E2D;&#x95F4;&#x4EF6;&#x7684;&#x7EC6;&#x8282;&#xFF0C;&#x8BF7;&#x53C2;&#x8003; &#x901A;&#x8FC7; <a href="http://www.expressjs.com.cn/starter/static-files.html">Express &#x6258;&#x7BA1;&#x9759;&#x6001;&#x8D44;&#x6E90;&#x6587;&#x4EF6;</a>&#x3002;</p>
<h2 id="t12. body-parser&#x4E2D;&#x95F4;&#x4EF6;">2. body-parser&#x4E2D;&#x95F4;&#x4EF6; <a href="#t12. body-parser&#x4E2D;&#x95F4;&#x4EF6;"> # </a></h2>
<p>body-parser&#x662F;&#x975E;&#x5E38;&#x5E38;&#x7528;&#x7684;&#x4E00;&#x4E2A;express&#x4E2D;&#x95F4;&#x4EF6;&#xFF0C;&#x4F5C;&#x7528;&#x662F;&#x5BF9;post&#x8BF7;&#x6C42;&#x7684;&#x8BF7;&#x6C42;&#x4F53;&#x8FDB;&#x884C;&#x89E3;&#x6790;&#x3002;&#x4F7F;&#x7528;&#x975E;&#x5E38;&#x7B80;&#x5355;&#xFF0C;&#x4EE5;&#x4E0B;&#x4E24;&#x884C;&#x4EE3;&#x7801;&#x5DF2;&#x7ECF;&#x8986;&#x76D6;&#x4E86;&#x5927;&#x90E8;&#x5206;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;&#x3002;</p>
<pre><code class="lang-js">app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ <span class="hljs-attr">extended</span>: <span class="hljs-literal">false</span> }));
</code></pre>
<h3 id="t22.1 http&#x62A5;&#x6587;&#x5934;">2.1 http&#x62A5;&#x6587;&#x5934; <a href="#t22.1 http&#x62A5;&#x6587;&#x5934;"> # </a></h3>
<pre><code class="lang-js">POST / HTTP/<span class="hljs-number">1.1</span>
Host: <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>:<span class="hljs-number">8080</span>
Content-Type: text/html; charset=utf8
Content-Encoding: gzip

zfpx
</code></pre>
<ul>
<li>Content-Type&#xFF1A;&#x8BF7;&#x6C42;&#x62A5;&#x6587;&#x4E3B;&#x4F53;&#x7684;&#x7C7B;&#x578B;&#x3001;&#x7F16;&#x7801;&#x3002;&#x5E38;&#x89C1;&#x7684;&#x7C7B;&#x578B;&#x6709;text/plain&#x3001;application/json&#x3001;application/x-www-form-urlencoded&#x3002;&#x5E38;&#x89C1;&#x7684;&#x7F16;&#x7801;&#x6709;utf8&#x3001;gbk&#x7B49;&#x3002;</li>
<li>Content-Encoding&#xFF1A;&#x58F0;&#x660E;&#x62A5;&#x6587;&#x4E3B;&#x4F53;&#x7684;&#x538B;&#x7F29;&#x683C;&#x5F0F;&#xFF0C;&#x5E38;&#x89C1;&#x7684;&#x53D6;&#x503C;&#x6709;gzip&#x3001;deflate&#x3001;identity&#x3002;
&#x62A5;&#x6587;&#x4E3B;&#x4F53;&#xFF1A;&#x8FD9;&#x91CC;&#x662F;&#x4E2A;&#x666E;&#x901A;&#x7684;&#x6587;&#x672C;&#x5B57;&#x7B26;&#x4E32;zfpx&#x3002;</li>
</ul>
<h3 id="t32.2 body-parser&#x5DE5;&#x4F5C;">2.2 body-parser&#x5DE5;&#x4F5C; <a href="#t32.2 body-parser&#x5DE5;&#x4F5C;"> # </a></h3>
<ul>
<li>&#x5904;&#x7406;&#x4E0D;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x8BF7;&#x6C42;&#x4F53;&#xFF1A;&#x6BD4;&#x5982;text&#x3001;json&#x3001;urlencoded&#x7B49;&#xFF0C;&#x5BF9;&#x5E94;&#x7684;&#x62A5;&#x6587;&#x4E3B;&#x4F53;&#x7684;&#x683C;&#x5F0F;&#x4E0D;&#x540C;&#x3002;</li>
<li>&#x5904;&#x7406;&#x4E0D;&#x540C;&#x7684;&#x7F16;&#x7801;&#xFF1A;&#x6BD4;&#x5982;utf8&#x3001;gbk&#x7B49;&#x3002;</li>
<li>&#x5904;&#x7406;&#x4E0D;&#x540C;&#x7684;&#x538B;&#x7F29;&#x7C7B;&#x578B;&#xFF1A;&#x6BD4;&#x5982;gzip&#x3001;deflate&#x7B49;&#x3002;</li>
</ul>
<h3 id="t42.3 &#x5904;&#x7406;&#x5185;&#x5BB9;&#x7C7B;&#x578B;">2.3 &#x5904;&#x7406;&#x5185;&#x5BB9;&#x7C7B;&#x578B; <a href="#t42.3 &#x5904;&#x7406;&#x5185;&#x5BB9;&#x7C7B;&#x578B;"> # </a></h3>
<h4 id="t52.3.1 &#x5904;&#x7406;text/plain">2.3.1 &#x5904;&#x7406;text/plain <a href="#t52.3.1 &#x5904;&#x7406;text/plain"> # </a></h4>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> http = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;http&apos;</span>);

<span class="hljs-keyword">var</span> options = {
    <span class="hljs-attr">hostname</span>: <span class="hljs-string">&apos;127.0.0.1&apos;</span>,
    <span class="hljs-attr">port</span>: <span class="hljs-string">&apos;3000&apos;</span>,
    <span class="hljs-attr">path</span>: <span class="hljs-string">&apos;/&apos;</span>,
    <span class="hljs-attr">method</span>: <span class="hljs-string">&apos;POST&apos;</span>,
    <span class="hljs-attr">headers</span>: {
        <span class="hljs-string">&apos;Content-Type&apos;</span>: <span class="hljs-string">&apos;text/plain&apos;</span>,
        <span class="hljs-string">&apos;Content-Encoding&apos;</span>: <span class="hljs-string">&apos;identity&apos;</span>
    }
};

<span class="hljs-keyword">var</span> client = http.request(options, (res) =&gt; {
    res.pipe(process.stdout);
});

client.end(<span class="hljs-string">&apos;zfpx&apos;</span>);
</code></pre>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> http = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;http&apos;</span>);

<span class="hljs-keyword">var</span> parse = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">req, done</span>) </span>{
    <span class="hljs-keyword">let</span> arr = [];
    req.on(<span class="hljs-string">&apos;data&apos;</span>, data =&gt; {
        arr.push(data);
    });

    req.on(<span class="hljs-string">&apos;end&apos;</span>, () =&gt; {
        <span class="hljs-keyword">let</span> result = Buffer.concat(arr);
        done(result);
    });
};

<span class="hljs-keyword">var</span> server = http.createServer(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">req, res</span>) </span>{
    parse(req, (chunks) =&gt; {
        res.end(chunks)
    });
});

server.listen(<span class="hljs-number">3000</span>);
</code></pre>
<h4 id="t62.3.2 &#x5904;&#x7406;application/json">2.3.2 &#x5904;&#x7406;application/json <a href="#t62.3.2 &#x5904;&#x7406;application/json"> # </a></h4>
<pre><code class="lang-js"><span class="hljs-string">&apos;Content-Type&apos;</span>: <span class="hljs-string">&apos;application/json&apos;</span>,
client.end( <span class="hljs-built_in">JSON</span>.stringify({<span class="hljs-attr">name</span>:zfpx}) );
</code></pre>
<pre><code class="lang-js"> <span class="hljs-keyword">var</span> json = <span class="hljs-built_in">JSON</span>.parse( chunks.toString() );
</code></pre>
<h4 id="t72.3.3 &#x5904;&#x7406;application/x-www-form-urlencoded">2.3.3 &#x5904;&#x7406;application/x-www-form-urlencoded <a href="#t72.3.3 &#x5904;&#x7406;application/x-www-form-urlencoded"> # </a></h4>
<pre><code class="lang-js">&apos;Content-Type&apos;: &apos;form/x-www-form-urlencoded&apos;,
client.end( querystring.stringify({name:&apos;zfpx}) );
</code></pre>
<pre><code class="lang-js"> <span class="hljs-keyword">var</span> body = querystring.parse( chunks.toString() );
</code></pre>
<h2 id="t82.4 &#x5904;&#x7406;&#x4E0D;&#x540C;&#x7F16;&#x7801;">2.4 &#x5904;&#x7406;&#x4E0D;&#x540C;&#x7F16;&#x7801; <a href="#t82.4 &#x5904;&#x7406;&#x4E0D;&#x540C;&#x7F16;&#x7801;"> # </a></h2>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> iconv = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;iconv-lite&apos;</span>);
<span class="hljs-keyword">var</span> encoding = <span class="hljs-string">&apos;gbk&apos;</span>;
<span class="hljs-string">&apos;Content-Type&apos;</span>: <span class="hljs-string">&apos;text/plain; charset=&apos;</span> + encoding,
<span class="hljs-keyword">var</span> buff = iconv.encode(<span class="hljs-string">&apos;zfpx&apos;</span>, encoding);
</code></pre>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> contentType = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;content-type&apos;</span>);
<span class="hljs-keyword">var</span> obj = contentType.parse(req.headers[<span class="hljs-string">&apos;content-type&apos;</span>]);
<span class="hljs-keyword">var</span> charset = obj.parameters.charset;
<span class="hljs-keyword">var</span> body = iconv.decode(chunks, charset);
</code></pre>
<h2 id="t92.5 &#x5904;&#x7406;&#x4E0D;&#x540C;&#x538B;&#x7F29;&#x7C7B;&#x578B;">2.5 &#x5904;&#x7406;&#x4E0D;&#x540C;&#x538B;&#x7F29;&#x7C7B;&#x578B; <a href="#t92.5 &#x5904;&#x7406;&#x4E0D;&#x540C;&#x538B;&#x7F29;&#x7C7B;&#x578B;"> # </a></h2>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> zlib = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;zlib&apos;</span>);
<span class="hljs-string">&apos;Content-Encoding&apos;</span>: <span class="hljs-string">&apos;gzip&apos;</span>
<span class="hljs-keyword">var</span> buff = zlib.gzipSync(<span class="hljs-string">&apos;zfpx&apos;</span>);
client.end(buff);
</code></pre>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> contentEncoding = req.headers[<span class="hljs-string">&apos;content-encoding&apos;</span>];
<span class="hljs-keyword">if</span>(contentEncoding === <span class="hljs-string">&apos;gzip&apos;</span>) {
  stream = zlib.createGunzip();
  req.pipe(stream);
}

</code></pre>
<h2 id="t102.6 multipart/form-data">2.6 multipart/form-data <a href="#t102.6 multipart/form-data"> # </a></h2>

        <div class="copyright">Powered by <a href="https://github.com/jaywcjlove/idoc" target="_blank">idoc</a>. Dependence <a href="https://nodejs.org">Node.js</a> run.</div>
    </div>
    
</div>

<script src="https://cdn.bootcss.com/jquery/3.0.0/jquery.js"></script>
<script>
$('.warpper .page-toc ul ul li a').on('click',function(){
  $('.warpper .page-toc ul ul li a').removeClass('my-active')
  $(this).addClass('my-active')
})
  // if (!$('.understand-me').length) {
  //   var bar = $(window).height() - $('.navbar ').height() - $('.page-toc').position().top;
  //   var count = bar / 26 / 2;
  //   var barHeight = $('.page-toc').outerHeight();
  //   $('.page-toc li').eq(0).children('a').addClass('red');
  //   var arr = [];
  //   $("h1,h2,h3,h4,h5,h6").each(function () {
  //     arr.push($(this).position().top);
  //   });
  //   var timer
  //   function dark() {
  //     clearTimeout(timer)
  //      timer = setTimeout(function () {
  //      var top = Math.abs($('.page-toc > ul').position().top);
  //      var cur = $('.content').scrollTop();
  //      for (var i = arr.length; i >= 0; i--) {
  //        if (arr[i] <= cur) {
  //          break;
  //        }
  //      }
  //      if (i === -1) {
  //        i = 0;
  //      }
  //      $('.page-toc li a').removeClass('red');
  //      $('.page-toc li').eq(i).children('a').addClass('red');
  //      let height = $('.page-toc li').eq(i).position().top-$('.page-toc').height(); // 如果当前的offset出去了 回到中间可好？
  //      $('.page-toc').scrollTop(height+$('.page-toc').height()/2);
  //    },200)
  //   }

  //   $('.content').on('scroll', dark);
  // }
</script>
<style>

    /* ::-webkit-scrollbar{width:14px;}
    ::-webkit-scrollbar-track{background-color:transparent;}
    ::-webkit-scrollbar-thumb{background-color:transparent;}
    ::-webkit-scrollbar-thumb:hover {background-color:transparent}
    ::-webkit-scrollbar-thumb:active {background-color:transparent} */

    .page-toc > ul .red {
        background: #f3f3f3;
        z-index: 1;
        border-left: 3px solid #009a61;
        -webkit-transition: all .2s ease;
        transition: all .2s ease;
        color: #000
    }





</style>
</body>
</html>
